/*
 * @Description: 
 * @Version: 2.0
 * @Autor: wangmiao
 * @Date: 2022-10-11 17:48:30
 * @LastEditors: wangmiao
 * @LastEditTime: 2022-10-12 15:14:54
 */





// 源对象

const personInfo = {
  name: '张三',
  age: 18,
  get value() {
    console.log(this) // 这时this指的是代理对象proxy
    return this.name
  }
};

const proxy = new Proxy(personInfo, {

  get(target, key, receiver) { // receiver：这里表示代理对象proxy
    
    console.log(key); // 打印两次，第一次为value，第二次为name

    return Reflect.get(target, key, receiver); // Reflect表示反射
  },
  set(target, key, value) {
    const result = Reflect.set(target, key, value, receiver);
    
    return result;
  }
});
console.log(proxy.value)

